<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
	<title>Vorpal: Scripting Language Reference</title>
	<link rel="stylesheet" type="text/css" href="styles.css" media="screen" />
</head>
<body>

<!--TOP-NAV-->
	<h1>Vorpal: Scriping Language Reference (Preliminary)</h1>
	<div id="top-nav"><ul id="top-nav-list">
		<li></li>
		<li> - <a href="fundamentals.html">Fundamentals</a></li>
		<li> - <a href="keywords.html">Keywords</a></li>
		<li> - <a href="types.html">Types</a></li>
		<li> - <a href="operators.html">Operators</a></li>
		<li> - <a href="methods.html">Methods</a></li>
		<li> - <a href="objects.html">Objects</a></li>
		<li> - </li>
	</ul></div>
<!--END-TOP-NAV-->

	<h2>Keywords</h2>
	
	<h3><a name="comment">Comment</a></h3>
	<p>
		Vorpal supports single line comments starting with a '<code># </code>' and running to 
		the end of the line or the next # character (whichever is found first).
	<p>
	
	<h3>Loops</h3>
	
	<h4>While</h4>
	<p>
		<code>while(<i>Boolean expression</i>){<i>statement</i>}</code>
	</p>
	<p>
		Executes the code block in <i>statement</i> while the <i>Boolean expression</i>
		evaluates to TRUE.
	</p>
	<p>
		Examples:
	</p>
	<ul>
		<li><code>while(sys.true()){'loop'.print()}</code> prints '<code>loop</code>' infinitely many times</li>
	</ul>
	
	<h4>For</h4>
	<p>
		<code>for(<i>initial</i>, <i>loop-test</i>, <i>loop-count</i>){<i>statement</i>}
	</p>
	<p>
		Initialises a loop control variable with the statement <i>initial</i>,
		and executes the code block in <i>statement</i> performing the
		statement <i>loop-count</i> on every loop iteration. Loop terminates when
		the Boolean expression <i>loop-test</i> evaluates to FALSE.
	<p>
	<p>
		Examples:
	</p>
	<ul>
		<li><code>for(x = 0, x < 4, x = x + 1){x.print()}</code></li>
	</ul>
	
	<h3>Conditionals</h3>
	
	<h4>If</h4>
	<p>
		<code>if(<i>Boolean expression</i>){<i>statement</i>}</code>
	</p>
	<p>
		Executes the code block in <i>statement</i> if the <i>Boolean expression</i>
		evaluates to TRUE.
	</p>
	<p>
		Examples:
	</p>
	<ul>
		<li><code>if(sys.true()){'yes'.print()}</code> prints '<code>yes</code>' once</li>
		<li><code>if(sys.false()){'no'.print()}</code> does nothing</li>
	</ul>

	<h4>If...Else</h4>
	<p>
		<code>if(<i>Boolean expression</i>){<i>statement1</i>} else{<i>statement2</i>}</code>
	</p>
	<p>
		Executes the code block in <i>statement1</i> if the <i>Boolean expression</i>
		evaluates to TRUE, otherwise executes <i>statement2</i>.
	</p>
	<p>
		Examples:
	</p>
	<ul>
		<li><code>if(sys.true()){'yes'.print()} else{'no'.print()}</code> prints '<code>yes</code>' once</li>
		<li><code>if(sys.false()){'yes'.print()} else{'no'.print()}</code> prints '<code>no</code>' once</li>
	</ul>
	
	<h4>If...Elseif...Else</h4>
	<p>
		<code>
			if(<i>Boolean expression</i>){<i>statement 1</i>}<br>
			elseif(<i>Boolean expression 2</i>){<i>statement 2</i>}<br>
			...<br>
			elseif(<i>Boolean expression n</i>){<i>statement n</i>}<br>
			else{<i>statement final</i>}
		</code>
	</p>
	<p>
		Executes the code block in <i>statement 1</i> if <i>Boolean expression 1</i>
		evaluates to TRUE, otherwise tries the same for <i>statement 2...n</i> and
		so on. If none of the conditionals are met, <i>statement final</i> is
		executed.
	</p>
	<p>
		Examples:
	</p>
	<ul>
		<li>
			<code>
				a = 1<br>
				if(a = 1){'one'.print()}<br>
				elsif(a = 2){'two'.print()}<br>
				else{'?'.print()}
			</code>
		</li>
	</ul>
	
	<h3>Objects and Methods</h3>
	
	<h4><a name="method">Method</a></h4>
	<p>
		<code>method(<i>argument list</i>){<i>statement</i>}</code>
	</p>
	<p>
		Creates and returns method taking a comma separated <i>argument list</i> with behaviour in <i>statement</i>.
	</p>
	<p>
		Examples:
	</p>
	<ul>
		<li><code>say = method(arg){arg.print()}</code> declares a method called '<code>say()</code>' that prints <code>arg</code></li>
	</ul>
	
	<h4>Return</h4>
	<p>
		<code>return(<i>expression</i>)</code>
	</p>
	<p>
		Inside a method, sets the return value to <i>expression</i> and terminates method execution.
	</p>
	<p>
		Examples:
	</p>
	<ul>
		<li><code>me = method(arg){return(arg)}</code> declares a method called <code>me()</code> that returns its input <code>arg</code></li>
	</ul>
	
	<h4><a name="self">Self</a></h4>
	<p>
		<code>self</code>
	</p>
	<p>
		Inside a method, returns a reference to the parent object.
	</p>
	<p>
		Examples:
	</p>
	<ul>
		<li><code>a.me = method(){return(self)}</code> declares a method called <code>me()</code> in <code>a</code> that returns <code>a</code> itself</li>
	</ul>
	
	<h4>New</h4>
	<p>
		<code>new(<i>object</i>)</code>
	</p>
	<p>
		Creates and returns a new instance of <i>object</i>.
	</p>
	<p>
		Examples:
	</p>
	<ul>
		<li><code>b = new(a)</code> creates a new instance of the <code>a</code> object and stores it in <code>b</code></li>
	</ul>
</body>
</html>
